<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/PhyLayerBattery.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00476.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">PhyLayerBattery.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
<a name="l00002"></a>00002 <span class="comment">// This program is free software: you can redistribute it and/or modify</span>
<a name="l00003"></a>00003 <span class="comment">// it under the terms of the GNU Lesser General Public License as published by</span>
<a name="l00004"></a>00004 <span class="comment">// the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00005"></a>00005 <span class="comment">// (at your option) any later version.</span>
<a name="l00006"></a>00006 <span class="comment">//</span>
<a name="l00007"></a>00007 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00008"></a>00008 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00009"></a>00009 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00010"></a>00010 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00011"></a>00011 <span class="comment">//</span>
<a name="l00012"></a>00012 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00013"></a>00013 <span class="comment">// along with this program.  If not, see http://www.gnu.org/licenses/.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#ifndef PHYLAYERBATTERY_H_</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor">#define PHYLAYERBATTERY_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;MiXiMDefs.h&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;PhyLayer.h&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;HostState.h&quot;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">class </span><a class="code" href="a00133.html" title="Stores information which is needed by the physical layer when sending a MacPkt.">MacToPhyControlInfo</a>;
<a name="l00024"></a>00024 <span class="keyword">class </span>MacPkt;
<a name="l00025"></a>00025 
<a name="l00055"></a><a class="code" href="a00174.html">00055</a> <span class="keyword">class </span>MIXIM_API <a class="code" href="a00174.html" title="Extends PhyLayer by adding power consumption for tx, rx and idle.">PhyLayerBattery</a> : <span class="keyword">public</span> <a class="code" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> {
<a name="l00056"></a>00056 <span class="keyword">public</span>:
<a name="l00057"></a>00057   <span class="keyword">typedef</span> MacPkt* macpkt_ptr_t;
<a name="l00058"></a>00058 <span class="keyword">protected</span>:
<a name="l00060"></a><a class="code" href="a00174.html#a0100994772e797d41df4c41b4b9ad475">00060</a>   <span class="keywordtype">int</span> <a class="code" href="a00174.html#a0100994772e797d41df4c41b4b9ad475" title="Number of power consuming activities (accounts).">numActivities</a>;
<a name="l00061"></a>00061 
<a name="l00064"></a>00064   <span class="keywordtype">double</span> sleepCurrent, rxCurrent, decodingCurrentDelta, txCurrent;
<a name="l00069"></a>00069   <span class="keywordtype">double</span> setupRxCurrent, setupTxCurrent, rxTxCurrent, txRxCurrent;
<a name="l00076"></a><a class="code" href="a00174.html#a1eb13993a65f4147d7f99c936b4143c7">00076</a>   <span class="keyword">enum</span> <a class="code" href="a00174.html#a1eb13993a65f4147d7f99c936b4143c7" title="Defines the power consuming activities (accounts) of the NIC. Should be the same as defined in the de...">Activities</a> {
<a name="l00077"></a>00077     SLEEP_ACCT=0,
<a name="l00078"></a>00078     RX_ACCT,
<a name="l00079"></a>00079     TX_ACCT,
<a name="l00080"></a>00080     SWITCHING_ACCT,
<a name="l00081"></a>00081     DECIDER_ACCT,
<a name="l00082"></a>00082   };
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="keyword">protected</span>:
<a name="l00093"></a>00093   <span class="keyword">virtual</span> <a class="code" href="a00070.html" title="The basic Decider class.">Decider</a>* <a class="code" href="a00173.html#a6f0907cd759351336c159c6e222beceb" title="Creates and returns an instance of the decider with the specified name.">getDeciderFromName</a>(<span class="keyword">const</span> std::string&amp; name, ParameterMap&amp; params);
<a name="l00094"></a>00094 
<a name="l00106"></a><a class="code" href="a00174.html#a396a3436d9a7e9116f9c06b5158029ab">00106</a>   <span class="keyword">virtual</span> <span class="keywordtype">double</span> calcTXCurrentForPacket(macpkt_ptr_t <span class="comment">/*pkt*/</span>, <a class="code" href="a00133.html" title="Stores information which is needed by the physical layer when sending a MacPkt.">MacToPhyControlInfo</a>* <span class="comment">/*cInfo*/</span>)<span class="keyword"> const</span>
<a name="l00107"></a>00107 <span class="keyword">  </span>{ <span class="keywordflow">return</span> -1.0; }
<a name="l00108"></a>00108 
<a name="l00110"></a>00110   <span class="keyword">virtual</span> <span class="keywordtype">void</span> setRadioCurrent(<span class="keywordtype">int</span> rs);
<a name="l00111"></a>00111 
<a name="l00114"></a>00114   <span class="keyword">virtual</span> <span class="keywordtype">void</span> setSwitchingCurrent(<span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to);
<a name="l00115"></a>00115 
<a name="l00124"></a>00124   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00029.html#a17b1d469775962d23835dd5f43a639ac" title="Handles messages received from the upper layer through the data gate.">handleUpperMessage</a>(cMessage* msg);
<a name="l00125"></a>00125 
<a name="l00132"></a>00132   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00029.html#ac8e87dac89d0c0daa01a8d430be7e7b6" title="Handles messages received from the channel (probably AirFrames).">handleAirFrame</a>(airframe_ptr_t frame);
<a name="l00133"></a>00133 
<a name="l00140"></a>00140   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00027.html#a44220aa650488eee8ad121f8bc599265" title="Called whenever the hosts state changes.">handleHostState</a>(<span class="keyword">const</span> <a class="code" href="a00098.html" title="HostState is published by the battery to announce host failure.">HostState</a>&amp; state);
<a name="l00141"></a>00141 
<a name="l00145"></a>00145   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00029.html#aa1de743a3d3ba652c1f3b84b34585743" title="Called the moment the simulated switching process of the MiximRadio is finished.">finishRadioSwitching</a>(<span class="keywordtype">bool</span> bSendCtrlMsg = <span class="keyword">true</span>);
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 <span class="keyword">public</span>:
<a name="l00148"></a>00148   <a class="code" href="a00174.html" title="Extends PhyLayer by adding power consumption for tx, rx and idle.">PhyLayerBattery</a>()
<a name="l00149"></a>00149     : <a class="code" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a>()
<a name="l00150"></a>00150     , numActivities(0)
<a name="l00151"></a>00151     , sleepCurrent(0), rxCurrent(0), decodingCurrentDelta(0), txCurrent(0)
<a name="l00152"></a>00152     , setupRxCurrent(0), setupTxCurrent(0), rxTxCurrent(0), txRxCurrent(0)
<a name="l00153"></a>00153   {}
<a name="l00154"></a>00154   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00029.html#a08704deaf03b73c8eda67cc60e670853" title="OMNeT++ initialization function.">initialize</a>(<span class="keywordtype">int</span> stage);
<a name="l00155"></a>00155 
<a name="l00165"></a>00165   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00029.html#a81153199f268b4831f42b20b06959764" title="Does nothing. For an actual power supporting phy see &quot;PhyLayerBattery&quot;.">drawCurrent</a>(<span class="keywordtype">double</span> amount, <span class="keywordtype">int</span> activity);
<a name="l00166"></a>00166 
<a name="l00170"></a>00170   <span class="keyword">virtual</span> simtime_t <a class="code" href="a00029.html#a5170b3aadae25dc6b9e61974076be04b" title="Tells the BasePhyLayer to switch to the specified radio state.">setRadioState</a>(<span class="keywordtype">int</span> rs);
<a name="l00171"></a>00171 };
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 <span class="preprocessor">#endif </span><span class="comment">/* PHYLAYERBATTERY_H_ */</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>PhyLayerBattery.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
